/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frontera;

import control.FlujoMedicion;
import entidad.Medicion;

/**
 *
 * @author Admin
 */
public class panelActual extends javax.swing.JPanel implements Observer {

    /**
     * Creates new form panelActual
     */
    private panelActual() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel_Temperatura = new javax.swing.JLabel();
        jLabel_Pluviosidad = new javax.swing.JLabel();
        jLabel_Pres_Atmosferica = new javax.swing.JLabel();
        jTextField_Temperatura = new javax.swing.JTextField();
        jTextField_Pluviosidad = new javax.swing.JTextField();
        jTextField_Pres_Atmosferica = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jDateChooser1 = new com.toedter.calendar.JDateChooser();
        jLabel4 = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Valor Actual"));

        jLabel_Temperatura.setText("Temperatura:");

        jLabel_Pluviosidad.setText("Pluviosidad:");

        jLabel_Pres_Atmosferica.setText("Presión Atmosferica:");

        jTextField_Temperatura.setEditable(false);

        jTextField_Pluviosidad.setEditable(false);

        jTextField_Pres_Atmosferica.setEditable(false);

        jLabel1.setText("ºC");

        jLabel2.setText("<html>cm<sup>3</sup></html>");

        jLabel3.setText("bar");

        jDateChooser1.setEnabled(false);

        jLabel4.setText("Medición Tomada el dia:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_Pres_Atmosferica)
                                .addGap(28, 28, 28)
                                .addComponent(jTextField_Pres_Atmosferica))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_Pluviosidad)
                                .addGap(70, 70, 70)
                                .addComponent(jTextField_Pluviosidad, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_Temperatura)
                                .addGap(61, 61, 61)
                                .addComponent(jTextField_Temperatura, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jDateChooser1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(5, 5, 5))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Temperatura)
                    .addComponent(jTextField_Temperatura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Pluviosidad)
                    .addComponent(jTextField_Pluviosidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel_Pres_Atmosferica)
                    .addComponent(jTextField_Pres_Atmosferica, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jDateChooser1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    public synchronized static panelActual getInstance() {
        if (m_instance == null) {
            m_instance = new panelActual();
        }

        return m_instance;
    }
    private static panelActual m_instance;
    private Medicion actual;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private com.toedter.calendar.JDateChooser jDateChooser1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel_Pluviosidad;
    private javax.swing.JLabel jLabel_Pres_Atmosferica;
    private javax.swing.JLabel jLabel_Temperatura;
    private javax.swing.JTextField jTextField_Pluviosidad;
    private javax.swing.JTextField jTextField_Pres_Atmosferica;
    private javax.swing.JTextField jTextField_Temperatura;
    // End of variables declaration//GEN-END:variables

    @Override
    public void update() {
        actual = FlujoMedicion.getInstance().ultimaMedicion();
        jTextField_Temperatura.setText(Double.toString(actual.getTemperatura()));
        jTextField_Pluviosidad.setText(Double.toString(actual.getPluviosidad()));
        jTextField_Pres_Atmosferica.setText(Double.toString(actual.getPresionAtmosferica()));
        jDateChooser1.setDate(actual.getFecha());
    }
}
